/*
 * Copyright (C) 2010 Fores Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package jp.fores.midori.client.caller;

import jp.fores.midori.core.util.ClassUtil;

/**
 * 複数のサーバーに対してリモートプロシージャーコールを行うインターフェースの共通処理を実装した抽象クラス。<br>
 */
public abstract class AbstractRPCClientCaller implements RPCClientCaller {
	//==========================================================
	//メソッド

	//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
	//抽象メソッドの実装

	/**
	 * {@inheritDoc}
	 */
	@Override
	public <T> T remoteCall(Class<T> returnClass, URLListGetter urlListGetter,
			String methodName, Object... args) throws Exception {
		//実際に処理を行うメソッドを呼び出す
		Object result = remoteCall(urlListGetter, methodName, args);

		//戻り値の型補正を行って返す
		return ClassUtil.adjustObjectType(result, returnClass);
	}
}
